package com.yuan.base.widget;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.ScrollView;

/**
 * scrollview的监听类(当前只实现了滑动到底部的监听)
 */
public class ListenerScrollView extends ScrollView {

	private OnScrollToBottomListener onScrollToBottom;

	public ListenerScrollView(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	public ListenerScrollView(Context context) {
		super(context);
	}

	@Override
	protected void onOverScrolled(int scrollX, int scrollY, boolean clampedX, boolean clampedY) {
		super.onOverScrolled(scrollX, scrollY, clampedX, clampedY);
		if (scrollY > 100 && null != onScrollToBottom) {
			onScrollToBottom.onScrollBottomListener(clampedY);
		}
	}

	public void setOnScrollToBottomLintener(OnScrollToBottomListener listener) {
		onScrollToBottom = listener;
	}

	public interface OnScrollToBottomListener {
		void onScrollBottomListener(boolean isBottom);
	}
}
